package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsAddress;
import com.qf.pojo.DtsRegion;
import com.qf.service.RegionService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/admin/region")
public class RegionController {
    @Autowired
    private RegionService regionService;








    //http://localhost:8080/admin/region/list?
    // page=1&limit=20&name=%E5%8C%97%E4%BA%AC&code=11
    @RequiresPermissions("admin:region:list")
    @RequiresPermissionsDesc(menu = {"商场管理","行政区域"},button = "查询")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "20") Integer limit,
                       String name,Integer code,String sort,String order) {

        IPage<DtsRegion> iPage = regionService.findListByQuery(page,limit,name,code,sort,order);

        Map data=new HashMap();
        data.put("total",iPage.getTotal());
        data.put("items",iPage.getRecords());
        return ResponseUtil.ok(data);
    }
}
